function init(){
    var nd = new Date();
    var nowDate=nd.toLocaleDateString();
    alert("当前日期："+nowDate);
    ajaxCall("GET","../ComQuesServlet?method=getContentByDate&date="+nowDate,setQuestion);
}

function historyDetails(){
    var date=document.getElementById("historydate").innerText;
    ajaxCall("GET","../ComQuesServlet?method=getContentByDate&date="+date,setHistoryQuestion);
}
function setHistoryQuestion(res) {
    var obj = JSON.parse(res);
    var historyQuestion=document.getElementById("historyQuestion");
    historyQuestion.value =obj;
}

function setQuestion(res){
    var obj = JSON.parse(res);
    var tquestion=document.getElementById("tquestion");
    tquestion.value =obj;
}

function ajaxCall(method,url,callBackFunction){
    var httprequest=new XMLHttpRequest();
    httprequest.onreadystatechange=function(){
        if(httprequest.readyState==4&&httprequest.status==200){
            callBackFunction(httprequest.responseText);
        }
    }
    httprequest.open(method,url,false);
    httprequest.send();
}